﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;

namespace EHR.Ctrls.QueryDesign
{
    public partial class LogicOperatorItem : FilterItemBase
    {
        public bool IsAnd
        {
            get { return cmbOps.SelectedIndex == 0; }
            set { cmbOps.SelectedIndex = value ? 0 : 1; }
        }

        public LogicOperatorItem()
        {
            InitializeComponent();

            LayoutRoot.DataContext = this;
        }

        private void tbCol_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            RaiseClicked();
        }

        private void cmbOps_DropDownClosed(object sender, EventArgs e)
        {
            UpdateOp();
        }

        private void UpdateOp()
        {
            if (cmbOps == null)
            {
                return;
            }
            
            IsEditState = false;

            RaiseSaved();
        }
    }
}
